from rest_framework.serializers import ModelSerializer, DateTimeField, CharField

from wxcloudrun.models import WebSettings


class BaseSerializer(ModelSerializer):
    createdAt = DateTimeField(
        format="%Y-%m-%d %H:%M:%S", required=False, read_only=True
    )
    updatedAt = DateTimeField(
        format="%Y-%m-%d %H:%M:%S", required=False, read_only=True
    )


class WebSettingsSerializer(ModelSerializer):
    statistical_exclude_user_id = CharField(required=False, allow_blank=True)
    name = CharField(required=False, allow_blank=True)
    freight_code = CharField(required=False, allow_blank=True)

    class Meta:
        model = WebSettings
        fields = [
            "name",
            "goods_less_count",
            "goods_recycle_less_money",
            "goods_freight_money",
            "recharge_page_switch",
            "hidden_box_consume",
            "statistical_exclude_user_id",
            "freight_code",
        ]
